﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sahit.iSoilHotel.Domain.Seedwork.Specification;

namespace Sahit.iSoilHotel.Domain.MainBoundedContext.Tavern.Aggregates.RecordAgg
{
    public static class RecordSpecifications
    {
        public static Specification<Record> RecordSearch(Guid? recordID, int[] recordStatusIDs, Guid? roomTypeID, string roomNumber,Guid? roomID)
        {
            Specification<Record> specification = new DirectSpecification<Record>(r => true);
            if (recordID != null && recordID != Guid.Empty)
            {
                var recordIDsSpec = new DirectSpecification<Record>(r => recordID == r.ID);
                specification &= recordIDsSpec;
            }
            if (recordStatusIDs != null && recordStatusIDs.Length>0)
            {
                var recordStatusIDSpec = new DirectSpecification<Record>(r => recordStatusIDs.Contains(r.StatusID));
                specification &= recordStatusIDSpec;
            }
            if (roomTypeID!=null && roomTypeID != Guid.Empty)
            {
                var roomTypeIDSpec = new DirectSpecification<Record>(r => r.Room.RoomTypeID == roomTypeID);
                specification &= roomTypeIDSpec;
            }
            if (!String.IsNullOrEmpty(roomNumber))
            {
                var roomNumberSpec = new DirectSpecification<Record>(r => r.Room.Number == roomNumber);
                specification &= roomNumberSpec;
            }
            if (roomID != null && roomID != Guid.Empty)
            {
                var roomIDSpec = new DirectSpecification<Record>(r => r.Room.ID == roomID);
                specification &= roomIDSpec;
            }
            return specification;
        }
    }
}
